﻿<?xml version="1.0" encoding="utf-8"?>
<cms:formdefinition xmlns="http://www.composite.net/ns/management/bindingforms/std.ui.controls.lib/1.0" xmlns:internal="http://www.composite.net/ns/management/bindingforms/internal.ui.controls.lib/1.0" xmlns:f="http://www.composite.net/ns/management/bindingforms/std.function.lib/1.0" xmlns:cms="http://www.composite.net/ns/management/bindingforms/1.0">
  <cms:bindings>
    <cms:binding name="Function" type="Composite.Data.Types.IVisualFunction, Composite" />
    <cms:binding name="PreviewEventHandler" type="System.EventHandler" optional="true" />
    <cms:binding name="XhtmlBody" type="System.String" />
    <cms:binding name="EmbedableFieldsTypes" type="System.Collections.IEnumerable" />
    <cms:binding name="SourceTypeFullName" type="System.String" />
    <cms:binding name="PreviewTemplateId" type="System.Guid" />
    <cms:binding name="FieldNameList" type="System.Collections.IEnumerable" />
    <cms:binding name="TemplateList" type="System.Collections.IEnumerable" />
  </cms:bindings>
  <cms:layout>
    <TabPanels>
      <TabPanels.Label>
        <cms:read source="Function.Name" />
      </TabPanels.Label>
      <PlaceHolder Label="${Composite.Plugins.VisualFunction, Edit.PlaceHolderLabel}">
        <Heading Title="${Composite.Plugins.VisualFunction, Edit.HeadingTitel}">
          <Heading.Description>
            <cms:read source="SourceTypeFullName" />
          </Heading.Description>
        </Heading>
        <FieldGroup Label="${Composite.Plugins.VisualFunction, Edit.FieldGroupLabel}">
          <TextBox Label="${Composite.Plugins.VisualFunction, Edit.FunctionNameLabel}" Help="${Composite.Plugins.VisualFunction, Edit.FunctionNameHelp}">
            <TextBox.Text>
              <cms:bind source="Function.Name" />
            </TextBox.Text>
          </TextBox>
          <TextBox Label="${Composite.Plugins.VisualFunction, Edit.FunctionNamespaceLabel}" Help="${Composite.Plugins.VisualFunction, Edit.FunctionNamespaceHelp}">
            <TextBox.Text>
              <cms:bind source="Function.Namespace" />
            </TextBox.Text>
          </TextBox>
          <TextArea Label="${Composite.Plugins.VisualFunction, Edit.FunctionDescriptionLabel}" Help="${Composite.Plugins.VisualFunction, Edit.FunctionDescriptionHelp}">
            <TextArea.Text>
              <cms:bind source="Function.Description" />
            </TextArea.Text>
          </TextArea>
          <TextBox Label="${Composite.Plugins.VisualFunction, Edit.ItemListLenghtLabel}" Help="${Composite.Plugins.VisualFunction, Edit.ItemListLenghtHelp}" Type="integer">
            <TextBox.Text>
              <cms:bind source="Function.MaximumItemsToList" />
            </TextBox.Text>
          </TextBox>
          <KeySelector Label="${Composite.Plugins.VisualFunction, Edit.ItemSortingLabel}" Help="${Composite.Plugins.VisualFunction, Edit.ItemSortingHelp}">
            <KeySelector.Selected>
              <cms:bind source="Function.OrderbyFieldName" />
            </KeySelector.Selected>
            <KeySelector.Options>
              <cms:read source="FieldNameList" />
            </KeySelector.Options>
          </KeySelector>
          <BoolSelector TrueLabel="${Composite.Plugins.VisualFunction, Edit.ListSortingTrueLabel}" FalseLabel="${Composite.Plugins.VisualFunction, Edit.ListSortingFalseLabel}" Label="${Composite.Plugins.VisualFunction, Edit.ListSortingLabel}" Help="${Composite.Plugins.VisualFunction, Edit.ListSortingHelp}">
            <cms:bind source="Function.OrderbyAscending" />
          </BoolSelector>
          <KeySelector OptionsKeyField="Id" OptionsLabelField="Title" Label="${Composite.Plugins.VisualFunction, Edit.PreviewTemplateLabel}" Help="${Composite.Plugins.VisualFunction, Edit.PreviewTemplateHelp}">
            <KeySelector.Selected>
              <cms:bind source="PreviewTemplateId" />
            </KeySelector.Selected>
            <KeySelector.Options>
              <cms:read source="TemplateList" />
            </KeySelector.Options>
          </KeySelector>
        </FieldGroup>
      </PlaceHolder>
      <XhtmlEditor Label="${Composite.Plugins.VisualFunction, Edit.WYSIWYGLayoutLabel}">
        <XhtmlEditor.EmbedableFieldsTypes>
          <cms:read source="EmbedableFieldsTypes" />
        </XhtmlEditor.EmbedableFieldsTypes>
        <cms:bind source="XhtmlBody" />
      </XhtmlEditor>
      <f:NullCheck>
        <f:NullCheck.CheckValue>
          <cms:read source="PreviewEventHandler" />
        </f:NullCheck.CheckValue>
        <f:NullCheck.WhenNotNull>
          <internal:PreviewPanel Label="${Composite.Plugins.VisualFunction, Edit.LabelPreview}">
            <internal:PreviewPanel.ClickEventHandler>
              <cms:read source="PreviewEventHandler" />
            </internal:PreviewPanel.ClickEventHandler>
          </internal:PreviewPanel>
        </f:NullCheck.WhenNotNull>
      </f:NullCheck>
    </TabPanels>
  </cms:layout>
</cms:formdefinition>